/*
 * SystemColorPalette.java  0.4.0 / Oct 25, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.swing.styles; // NOPMD

import java.util.WeakHashMap;

import com.cute4j.swing.graphics.Color;


/**
 * System Color Palette.
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public final class SystemColorPalette extends ColorPalette {

// Public Static Fields. -------------------------------------------------------

  private static WeakHashMap paletteCache;

// Static Initialization. ------------------------------------------------------

  static {
    paletteCache = new WeakHashMap();
  }

// Package-Private Fields. -----------------------------------------------------

  final String name;

// Public Constructors. --------------------------------------------------------

  /**
   * Constructs new SystemColorPalette object.
   */
  public SystemColorPalette() {
    this("System");
  }

// Package-Private Constructors. -----------------------------------------------

  SystemColorPalette(String name) {
    if (name == null) {
      throw new IllegalArgumentException("Null name");
    }
    this.name = name;
  }

// Overridden Methods. ---------------------------------------------------------

  /**
   * {@inheritDoc}
   */
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }
    if ((obj != null) && (obj.getClass() == getClass())) {
      SystemColorPalette palette = (SystemColorPalette)obj;
      return name.equals(palette.name);
    }
    return false;
  }

  /**
   * {@inheritDoc}
   */
  public int hashCode() {
    return getColorPalette().hashCode();
  }

  /**
   * {@inheritDoc}
   */
  public String getName() {
    return name;
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveBackgroundColor() {
    return getColorPalette().getActiveBackgroundColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveBackgroundColor() {
    return getColorPalette().getInactiveBackgroundColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledBackgroundColor() {
    return getColorPalette().getDisabledBackgroundColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveForegroundColor() {
    return getColorPalette().getActiveForegroundColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveForegroundColor() {
    return getColorPalette().getInactiveForegroundColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledForegroundColor() {
    return getColorPalette().getDisabledForegroundColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveBaseColor() {
    return getColorPalette().getActiveBaseColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveBaseColor() {
    return getColorPalette().getInactiveBaseColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledBaseColor() {
    return getColorPalette().getDisabledBaseColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveAlternateBaseColor() {
    return getColorPalette().getActiveAlternateBaseColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveAlternateBaseColor() {
    return getColorPalette().getInactiveAlternateBaseColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledAlternateBaseColor() {
    return getColorPalette().getDisabledAlternateBaseColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveTextColor() {
    return getColorPalette().getActiveTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveTextColor() {
    return getColorPalette().getInactiveTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledTextColor() {
    return getColorPalette().getDisabledTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveButtonColor() {
    return getColorPalette().getActiveButtonColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveButtonColor() {
    return getColorPalette().getInactiveButtonColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledButtonColor() {
    return getColorPalette().getDisabledButtonColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveButtonTextColor() {
    return getColorPalette().getActiveButtonTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveButtonTextColor() {
    return getColorPalette().getInactiveButtonTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledButtonTextColor() {
    return getColorPalette().getDisabledButtonTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveBrightTextColor() {
    return getColorPalette().getActiveBrightTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveBrightTextColor() {
    return getColorPalette().getInactiveBrightTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledBrightTextColor() {
    return getColorPalette().getDisabledBrightTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveLightColor() {
    return getColorPalette().getActiveLightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveLightColor() {
    return getColorPalette().getInactiveLightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledLightColor() {
    return getColorPalette().getDisabledLightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveMidlightColor() {
    return getColorPalette().getActiveMidlightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveMidlightColor() {
    return getColorPalette().getInactiveMidlightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledMidlightColor() {
    return getColorPalette().getDisabledMidlightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveDarkColor() {
    return getColorPalette().getActiveDarkColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveDarkColor() {
    return getColorPalette().getInactiveDarkColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledDarkColor() {
    return getColorPalette().getInactiveDarkColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveMidColor() {
    return getColorPalette().getActiveMidColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveMidColor() {
    return getColorPalette().getInactiveMidColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledMidColor() {
    return getColorPalette().getDisabledMidColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveShadowColor() {
    return getColorPalette().getActiveShadowColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveShadowColor() {
    return getColorPalette().getInactiveShadowColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledShadowColor() {
    return getColorPalette().getDisabledShadowColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveHighlightColor() {
    return getColorPalette().getActiveHighlightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveHighlightColor() {
    return getColorPalette().getInactiveHighlightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledHighlightColor() {
    return getColorPalette().getDisabledHighlightColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveHighlightedTextColor() {
    return getColorPalette().getActiveHighlightedTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveHighlightedTextColor() {
    return getColorPalette().getInactiveHighlightedTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledHighlightedTextColor() {
    return getColorPalette().getDisabledHighlightedTextColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveLinkColor() {
    return getColorPalette().getActiveLinkColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveLinkColor() {
    return getColorPalette().getInactiveLinkColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledLinkColor() {
    return getColorPalette().getDisabledLinkColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getActiveLinkVisitedColor() {
    return getColorPalette().getActiveLinkVisitedColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getInactiveLinkVisitedColor() {
    return getColorPalette().getInactiveLinkVisitedColor();
  }

  /**
   * {@inheritDoc}
   */
  public Color getDisabledLinkVisitedColor() {
    return getColorPalette().getDisabledLinkVisitedColor();
  }

// Private Methods. ------------------------------------------------------------

  private CustomColorPalette getColorPalette() {
    synchronized (paletteCache) {
      CustomColorPalette palette = (CustomColorPalette)paletteCache.get(name);
      if (palette == null) {
        palette = new CustomColorPalette(name);
        paletteCache.put(name, palette);
      }
      return palette;
    }
  }

}
